﻿<UserControl x:Class="Anagramme.Views.GameView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:conv="clr-namespace:Anagramme.Converters;assembly=Anagramme.Common"
             mc:Ignorable="d" 
             d:DataContext="{d:DesignData Source=/SampleData/GameViewModelSampleData.xaml}"
             d:DesignHeight="700" d:DesignWidth="400" >
    <UserControl.Resources>
        <conv:UpperCaseConverter x:Key="UpperCaseConverter" />
    </UserControl.Resources>
    <Grid Name="mainGrid" >
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="457*"/>
            <ColumnDefinition/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto" />
            <RowDefinition Height="Auto" />
            <RowDefinition />
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Grid HorizontalAlignment="Center" VerticalAlignment="Center">
            <Grid.RowDefinitions>
                <RowDefinition />
                <RowDefinition />
            </Grid.RowDefinitions>
            <TextBlock Style="{DynamicResource TexteImportant}"
                       Text="{Binding Path=Game.ROUND, Source={StaticResource ResourceKey=Resources}}" />
            <TextBlock x:Name="textRound" Grid.Row="1" HorizontalAlignment="Center" Style="{DynamicResource Titre}"
                       Text="{Binding Game.CurrentRound}" />
        </Grid>
        <Grid Grid.Row="1" VerticalAlignment="Center" Margin="6" >
            <Grid.RowDefinitions>
                <RowDefinition />
                <RowDefinition />
            </Grid.RowDefinitions>
            <Grid.ColumnDefinitions>
                <ColumnDefinition />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <TextBlock Style="{DynamicResource ResourceKey=Player1Text}"
                       Text="{Binding Path=MyTeam.Name, Mode=OneWay}" />
            <TextBlock Grid.Column="1" Margin="5,0,0,0" Style="{DynamicResource ResourceKey=Player1Text}"
                       Text="{Binding Path=MyTeam.Score, Mode=OneWay}" />
            <TextBlock Grid.Row="1" Margin="0,5,0,0" Style="{DynamicResource ResourceKey=Player2Text}"
                       Text="{Binding Path=OpponentTeam.Name, Mode=OneWay}" />
            <TextBlock Grid.Row="1" Grid.Column="1" Margin="5,5,0,0" Style="{DynamicResource ResourceKey=Player2Text}"
                       Text="{Binding Path=OpponentTeam.Score, Mode=OneWay}" />
        </Grid>
        <Grid Grid.Row="2" VerticalAlignment="Center" HorizontalAlignment="Center" >
            <Grid.ColumnDefinitions>
                <ColumnDefinition />
                <ColumnDefinition Width="Auto" />
            </Grid.ColumnDefinitions>
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <Grid Background="{DynamicResource ResourceKey=Word1BackgroundBrush}">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <Grid Margin="3">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition />
                        <ColumnDefinition Width="Auto" />
                    </Grid.ColumnDefinitions>
                    <TextBlock Style="{DynamicResource ResourceKey=Word1Text}"
                           DataContext="{Binding Path=MyWords[0], Mode=OneWay}"
                           Text="{Binding Path=Value, Mode=OneWay}" />
                    <Image Margin="5,0,0,0" Grid.Column="1"
                       DataContext="{Binding Path=MyWords[0], Mode=OneWay}"
                       Visibility="{Binding Path=IsFound, Mode=OneWay, Converter={StaticResource ResourceKey=BooleanToVisibilityConverter}, ConverterParameter=True}"
                       Source="/Anagramme.Common;component/Images/is_ready_to_play.png" />                    
                </Grid>
                <Grid Grid.Row="1" Margin="3">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="200" />
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>
                    <TextBox Name="OpponentWord1TextBox" Grid.Row="1" Style="{DynamicResource ResourceKey=Word1TextBox}"
					     DataContext="{Binding OpponentWords[0], Mode=OneWay}"
                         IsEnabled="{Binding Path=IsFound, Mode=OneWay, Converter={StaticResource ResourceKey=NotConverter}}"
                         Text="{Binding Path=Value, Converter={StaticResource ResourceKey=UpperCaseConverter}, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"  />
                    <Button Name="OpponentWord1Button" Margin="5,0,0,0" Grid.Column="1" Style="{DynamicResource Button}" VerticalAlignment="Center" IsTabStop="False"
                        Command="{Binding Path=SubmitWordCommand, Mode=OneTime}" CommandParameter="0"
                        Content="{Binding Path=Game.VALIDATE, Source={StaticResource ResourceKey=Resources}}" />
                </Grid>
            </Grid>
            <Grid Background="{DynamicResource ResourceKey=Word2BackgroundBrush}" Grid.Row="1" Margin="0,6,0,0" >
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <Grid Margin="3">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition />
                        <ColumnDefinition Width="Auto" />
                    </Grid.ColumnDefinitions>
                    <TextBlock Style="{DynamicResource ResourceKey=Word2Text}" 
					           DataContext="{Binding Path=MyWords[1], Mode=OneWay}"
                               Text="{Binding Path=Value, Mode=OneWay}" />
                    <Image Margin="5,0,0,0" Grid.Column="1"
                           DataContext="{Binding Path=MyWords[1], Mode=OneWay}"
                           Visibility="{Binding Path=IsFound, Mode=OneWay, Converter={StaticResource ResourceKey=BooleanToVisibilityConverter}, ConverterParameter=True}"
                           Source="/Anagramme.Common;component/Images/is_ready_to_play.png" />
                </Grid>
                <Grid Grid.Row="1" Margin="3">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="200" />
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>
                    <TextBox Name="OpponentWord2TextBox" Grid.Row="1" Style="{DynamicResource ResourceKey=Word2TextBox}"
					         DataContext="{Binding OpponentWords[1], Mode=OneWay}"
                             IsEnabled="{Binding Path=IsFound, Mode=OneWay, Converter={StaticResource ResourceKey=NotConverter}}"
                             Text="{Binding Path=Value, Mode=TwoWay, Converter={StaticResource ResourceKey=UpperCaseConverter}, UpdateSourceTrigger=PropertyChanged}"  />
                    <Button Name="OpponentWord2Button" Margin="5,0,0,0" Grid.Row="1" Grid.Column="1" Style="{DynamicResource Button}" VerticalAlignment="Center" IsTabStop="False"
                            Command="{Binding Path=SubmitWordCommand, Mode=OneTime}" CommandParameter="1"
                            Content="{Binding Path=Game.VALIDATE, Source={StaticResource ResourceKey=Resources}}" />
                </Grid>
            </Grid>
            <Grid Background="{DynamicResource ResourceKey=Word3BackgroundBrush}" Grid.Row="2" Margin="0,6,0,0" >
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <Grid Margin="3">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition />
                        <ColumnDefinition Width="Auto" />
                    </Grid.ColumnDefinitions>
                    <TextBlock Style="{DynamicResource ResourceKey=Word3Text}" 
					           DataContext="{Binding Path=MyWords[2], Mode=OneWay}"
                               Text="{Binding Path=Value, Mode=OneWay}" />
                    <Image Margin="5,0,0,0" Grid.Column="1"
				           DataContext="{Binding Path=MyWords[2], Mode=OneWay}"
                           Visibility="{Binding Path=IsFound, Mode=OneWay, Converter={StaticResource ResourceKey=BooleanToVisibilityConverter}, ConverterParameter=True}"
                           Source="/Anagramme.Common;component/Images/is_ready_to_play.png" />
                </Grid>
                <Grid Grid.Row="1" Margin="3">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="200" />
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>
                    <TextBox Name="OpponentWord3TextBox" Grid.Row="1" Style="{DynamicResource ResourceKey=Word3TextBox}"
					         DataContext="{Binding OpponentWords[2], Mode=OneWay}"
                             IsEnabled="{Binding Path=IsFound, Mode=OneWay, Converter={StaticResource ResourceKey=NotConverter}}"
                             Text="{Binding Path=Value, Mode=TwoWay, Converter={StaticResource ResourceKey=UpperCaseConverter}, UpdateSourceTrigger=PropertyChanged}" />
                    <Button Name="OpponentWord3Button" Margin="5,0,0,0" Grid.Row="1" Grid.Column="1" Style="{DynamicResource Button}" VerticalAlignment="Center" IsTabStop="False"
                            Command="{Binding Path=SubmitWordCommand, Mode=OneTime}" CommandParameter="2"
                            Content="{Binding Path=Game.VALIDATE, Source={StaticResource ResourceKey=Resources}}" />
                </Grid>
            </Grid>
            <Grid Background="{DynamicResource ResourceKey=Word4BackgroundBrush}" Grid.Row="3" Margin="0,6,0,0" >
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <Grid Margin="3">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition />
                        <ColumnDefinition Width="Auto" />
                    </Grid.ColumnDefinitions>
                    <TextBlock Style="{DynamicResource ResourceKey=Word4Text}"
					           DataContext="{Binding Path=MyWords[3], Mode=OneWay}"
                               Text="{Binding Path=Value, Mode=OneWay}" />
                    <Image Margin="5,0,0,0" Grid.Row="3" Grid.Column="1"
				           DataContext="{Binding Path=MyWords[3], Mode=OneWay}"
                           Visibility="{Binding Path=IsFound, Mode=OneWay, Converter={StaticResource ResourceKey=BooleanToVisibilityConverter}, ConverterParameter=True}"
                           Source="/Anagramme.Common;component/Images/is_ready_to_play.png" />
                </Grid>
                <Grid Grid.Row="1" Margin="3">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="200" />
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>
                    <TextBox Name="OpponentWord4TextBox" Grid.Row="1" Style="{DynamicResource ResourceKey=Word4TextBox}"
					         DataContext="{Binding OpponentWords[3], Mode=OneWay}"
                             IsEnabled="{Binding Path=IsFound, Mode=OneWay, Converter={StaticResource ResourceKey=NotConverter}}"
                             Text="{Binding Path=Value, Mode=TwoWay, Converter={StaticResource ResourceKey=UpperCaseConverter}, UpdateSourceTrigger=PropertyChanged}" />
                    <Button Name="OpponentWord4Button" Margin="5,0,0,0" Grid.Row="1" Grid.Column="1" Style="{DynamicResource Button}" VerticalAlignment="Center" IsTabStop="False"
                            Command="{Binding Path=SubmitWordCommand, Mode=OneTime}" CommandParameter="3"
                            Content="{Binding Path=Game.VALIDATE, Source={StaticResource ResourceKey=Resources}}" />
                </Grid>
            </Grid>
            <Grid Background="{DynamicResource ResourceKey=Word5BackgroundBrush}" Grid.Row="4" Margin="0,6,0,0" >
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <Grid Margin="3">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition />
                        <ColumnDefinition Width="Auto" />
                    </Grid.ColumnDefinitions>
                    <TextBlock Style="{DynamicResource ResourceKey=Word5Text}"
					           DataContext="{Binding Path=MyWords[4], Mode=OneWay}"
                               Text="{Binding Path=Value, Mode=OneWay}" />
                    <Image Margin="5,0,0,0" Grid.Column="1"
				           DataContext="{Binding Path=MyWords[4], Mode=OneWay}"
                           Visibility="{Binding Path=IsFound, Mode=OneWay, Converter={StaticResource ResourceKey=BooleanToVisibilityConverter}, ConverterParameter=True}"
                           Source="/Anagramme.Common;component/Images/is_ready_to_play.png" />
                </Grid>
                <Grid Grid.Row="1" Margin="3" >
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="200" />
                        <ColumnDefinition />
                    </Grid.ColumnDefinitions>
                    <TextBox Name="OpponentWord5TextBox" Grid.Row="1" Style="{DynamicResource ResourceKey=Word5TextBox}"
					         DataContext="{Binding OpponentWords[4], Mode=OneWay}"
                             IsEnabled="{Binding Path=IsFound, Mode=OneWay, Converter={StaticResource ResourceKey=NotConverter}}"
                             Text="{Binding Path=Value, Mode=TwoWay, Converter={StaticResource ResourceKey=UpperCaseConverter}, UpdateSourceTrigger=PropertyChanged}" />
                    <Button Name="OpponentWord5Button" Margin="5,0,0,0" Grid.Row="1" Grid.Column="1" Style="{DynamicResource Button}" VerticalAlignment="Center" IsTabStop="False"
                            Command="{Binding Path=SubmitWordCommand, Mode=OneTime}" CommandParameter="4"
                            Content="{Binding Path=Game.VALIDATE, Source={StaticResource ResourceKey=Resources}}" />
                </Grid>
            </Grid>
        </Grid>
        <StackPanel Grid.Row="3" HorizontalAlignment="Left" Margin="12,12,0,12" VerticalAlignment="Center" Orientation="Horizontal" >
            <TextBlock Style="{DynamicResource TexteImportant}"
                       Visibility="{Binding Path=Game.GameMode, Mode=OneWay, Converter={StaticResource ResourceKey=GameModesToVisibilityConverter}, ConverterParameter='False'}"
                       Text="{Binding Path=Game.TARGETROUNDS, StringFormat='{}{0} :', Source={StaticResource ResourceKey=Resources}}" />
            <TextBlock Style="{DynamicResource TexteImportant}"
                       Visibility="{Binding Path=Game.GameMode, Mode=OneWay, Converter={StaticResource ResourceKey=GameModesToVisibilityConverter}, ConverterParameter='True'}"
                       Text="{Binding Path=Game.TARGETSCORE, StringFormat='{}{0} :', Source={StaticResource ResourceKey=Resources}}" />
            <TextBlock Style="{DynamicResource TexteImportant}" 
                       Margin="5,0,0,0" Text="{Binding Path=Game.Target, Mode=OneWay}" />
        </StackPanel>
        <StackPanel Grid.Row="3" HorizontalAlignment="Right" Margin="0,12,12,12" Orientation="Horizontal">
            <Button x:Name="quitGameButton" Style="{DynamicResource Button}" IsTabStop="False"
                    Command="{Binding Path=QuitCommand, Mode=OneTime}"
                    Content="{Binding Path=Game.QUIT, Source={StaticResource ResourceKey=Resources}}" 
                    />
        </StackPanel>
    </Grid>
</UserControl>
